﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:vm="clr-namespace:ClearMine.VM;assembly=ClearMine.VM"
                    xmlns:m="clr-namespace:ClearMine.VM.Commands;assembly=ClearMine.VM"
                    xmlns:s="clr-namespace:ClearMine.Common.Messaging;assembly=ClearMine.Common"
                    xmlns:u="clr-namespace:ClearMine.Common.Utilities;assembly=ClearMine.Common"
                    xmlns:d="clr-namespace:ClearMine.Framework;assembly=ClearMine.Framework"
                    xmlns:c="clr-namespace:ClearMine.Framework.Controls;assembly=ClearMine.Framework"
                    xmlns:b="clr-namespace:ClearMine.Framework.Behaviors;assembly=ClearMine.Framework"
                    xmlns:logic="clr-namespace:ClearMine.GameDefinition;assembly=ClearMine.GameDefinition">
    <Rect x:Key="NumberViewbox">-0.2,-0.2 1.5,1.5</Rect>
    <Rect x:Key="MarkViewbox">-0.1,-0.1 1.2,1.2</Rect>
    <Rect x:Key="FaceViewbox">-0.1,-0.1 1.2,1.2</Rect>

    <ImageBrush x:Key="PreparedFaceBrush"
                Stretch="None"
                ImageSource="/ClearMine.Themes;component/Images/face-smile.png"
                Viewbox="{StaticResource FaceViewbox}">
    </ImageBrush>

    <ImageBrush x:Key="NormalFaceBrush"
                Stretch="None"
                ImageSource="/ClearMine.Themes;component/Images/face-cool.png"
                Viewbox="{StaticResource FaceViewbox}">
    </ImageBrush>

    <ImageBrush x:Key="TryFaceBrush"
                Stretch="None"
                ImageSource="/ClearMine.Themes;component/Images/face-worried.png"
                Viewbox="{StaticResource FaceViewbox}">
    </ImageBrush>

    <ImageBrush x:Key="WinFaceBrush"
                Stretch="None"
                ImageSource="/ClearMine.Themes;component/Images/face-win.png"
                Viewbox="{StaticResource FaceViewbox}">
    </ImageBrush>

    <ImageBrush x:Key="LosingFaceBrush"
                Stretch="None"
                ImageSource="/ClearMine.Themes;component/Images/face-sad.png"
                Viewbox="{StaticResource FaceViewbox}">
    </ImageBrush>

    <WaveEffect x:Key="waveEffect" />

    <ImageBrush x:Key="FlagBrush"
                Stretch="Uniform"
                ImageSource="/ClearMine.Themes;component/Images/flag.png"
                Viewbox="{StaticResource FaceViewbox}">
    </ImageBrush>

    <ImageBrush x:Key="QuestionBrush"
                Stretch="Uniform"
                ImageSource="/ClearMine.Themes;component/Images/flag-question.png"
                Viewbox="{StaticResource FaceViewbox}">
    </ImageBrush>

    <ImageBrush x:Key="TooManyFlagsBrush"
                Stretch="Uniform"
                ImageSource="/ClearMine.Themes;component/Images/warning.png"
                Viewbox="-0.1,-0.1 1.25,1.25">
    </ImageBrush>

    <ImageBrush x:Key="MineBrush"
                Stretch="Uniform"
                ImageSource="/ClearMine.Themes;component/Images/mine.png"
                Viewbox="{StaticResource FaceViewbox}">
    </ImageBrush>

    <ImageBrush x:Key="BomMineBrush"
                Stretch="Uniform"
                ImageSource="/ClearMine.Themes;component/Images/bang.png"
                Viewbox="{StaticResource FaceViewbox}">
    </ImageBrush>

    <DrawingBrush x:Key="WrongMineMark"
                  Stretch="Uniform"
                  Viewbox="{StaticResource FaceViewbox}">
        <DrawingBrush.Drawing>
            <GeometryDrawing Geometry="M0,0 L15,15 M15,0 L 0,15">
                <GeometryDrawing.Pen>
                    <Pen Brush="Black"
                         EndLineCap="Round"
                         StartLineCap="Round"
                         Thickness="1" />
                </GeometryDrawing.Pen>
            </GeometryDrawing>
        </DrawingBrush.Drawing>
    </DrawingBrush>

    <SolidColorBrush x:Key="PlaygroundBorderBrush" Color="Transparent" />

    <LinearGradientBrush x:Key="NewGameButtonBackground" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#FFEFEFEF" Offset="0" />
        <GradientStop Color="#FFD4D4D4" Offset="1" />
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="NewGameButtonMouseOverBackground" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#FFFBFBFB" Offset="0" />
        <GradientStop Color="#FFDEDEDE" Offset="1" />
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="NewGameButtonPressedBackground" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#FFCFCFCF" Offset="0" />
        <GradientStop Color="#FFD9D9D9" Offset="1" />
    </LinearGradientBrush>

    <Style x:Key="NewGameButtonStyle"
           TargetType="{x:Type Button}">
        <Setter Property="BorderThickness"
                Value="1" />
        <Setter Property="BorderBrush">
            <Setter.Value>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Color="#FFB8B8B8" Offset="0" />
                    <GradientStop Color="#FF929292" Offset="0" />
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="Background"
                Value="{StaticResource NewGameButtonBackground}" />
        <Setter Property="Width"
                Value="{Binding ActualHeight, RelativeSource={RelativeSource Self}}" />
        <Setter Property="FocusVisualStyle"
                Value="{DynamicResource EmptyFocusVisual}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <Border BorderThickness="{TemplateBinding BorderThickness}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            Background="{TemplateBinding Background}"
                            CornerRadius="3" Name="outBorder">
                        </Border>
                        <Border BorderThickness="1" CornerRadius="2" Margin="{TemplateBinding BorderThickness}">
                            <Border.BorderBrush>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                    <GradientStop Color="#FFFCFCFC" Offset="0" />
                                    <GradientStop Color="#FFDDDDDD" Offset="0" />
                                </LinearGradientBrush>
                            </Border.BorderBrush>
                            <ContentPresenter Name="icon" />
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused"
                                 Value="True">
                            <Setter Property="Effect" TargetName="outBorder">
                                <Setter.Value>
                                    <BlurEffect Radius="2" />
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsPressed"
                                 Value="True">
                            <Setter Property="RenderTransform" TargetName="icon">
                                <Setter.Value>
                                    <TranslateTransform X="1" Y="1" />
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver"
                     Value="True">
                <Setter Property="Background"
                        Value="{StaticResource NewGameButtonMouseOverBackground}"/>
            </Trigger>
            <Trigger Property="IsPressed"
                     Value="True">
                <Setter Property="Background"
                        Value="{StaticResource NewGameButtonPressedBackground}" />
            </Trigger>
            <Trigger Property="IsFocused"
                     Value="True">
                <Setter Property="BorderBrush">
                    <Setter.Value>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="#FFDF8A68" Offset="0" />
                            <GradientStop Color="#FFD47F5D" Offset="0" />
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

    <DrawingBrush x:Key="NormalCellBackground">
        <DrawingBrush.Drawing>
            <GeometryDrawing>
                <GeometryDrawing.Geometry>
                    <RectangleGeometry Rect="1,1 48,48" RadiusX="2" RadiusY="2" />
                </GeometryDrawing.Geometry>
                <GeometryDrawing.Brush>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                        <GradientStop Color="#FFF98759" Offset="0" />
                        <GradientStop Color="#FFE46633" Offset="1" />
                    </LinearGradientBrush>
                </GeometryDrawing.Brush>
                <GeometryDrawing.Pen>
                    <Pen Brush="#FFD1CFCD" Thickness="1"/>
                </GeometryDrawing.Pen>
            </GeometryDrawing>
        </DrawingBrush.Drawing>
    </DrawingBrush>

    <SolidColorBrush x:Key="PressedCellBackground"
                     Color="Transparent" />

    <DrawingBrush x:Key="ShownCellBackground">
        <DrawingBrush.Drawing>
            <GeometryDrawing>
                <GeometryDrawing.Geometry>
                    <RectangleGeometry Rect="1,1 48,48" RadiusX="2" RadiusY="2" />
                </GeometryDrawing.Geometry>
                <GeometryDrawing.Brush>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                        <GradientStop Color="#FFFCFBFA" Offset="0" />
                        <GradientStop Color="#FFDCD9D7" Offset="1" />
                    </LinearGradientBrush>
                </GeometryDrawing.Brush>
                <GeometryDrawing.Pen>
                    <Pen Brush="#FFD1CFCD" Thickness="1"/>
                </GeometryDrawing.Pen>
            </GeometryDrawing>
        </DrawingBrush.Drawing>
    </DrawingBrush>

    <DrawingBrush x:Key="Number1Brush"
                  Stretch="Uniform"
                  Viewbox="{StaticResource NumberViewbox}">
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <DrawingGroup.Children>
                    <GeometryDrawing Brush="#FF3A50C0"
                                     Geometry="F1 M 19.68,17L 19.68,52.04L 10.08,52.04L 10.08,29.3825C 8.51,30.5475 6.99126,31.49 5.52374,32.21C 4.05624,32.93 2.215,33.62 0,34.28L 0,26.6C 3.26,25.51 5.79125,24.1987 7.59375,22.6663C 9.39626,21.1337 10.8075,19.245 11.8275,17L 19.68,17 Z " />
                </DrawingGroup.Children>
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>
    <DrawingBrush x:Key="Number2Brush"
                  Stretch="Uniform"
                  Viewbox="{StaticResource NumberViewbox}">
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <DrawingGroup.Children>
                    <GeometryDrawing Brush="#FF176801"
                                     Geometry="F1 M 115.4,35.04L 86.6,35.04C 86.925,32.215 87.9175,29.5562 89.5775,27.0637C 91.2375,24.5712 94.35,21.59 98.915,18.12C 101.705,15.99 103.47,14.3737 104.21,13.2712C 104.95,12.1687 105.32,11.12 105.32,10.125C 105.32,9.05499 104.933,8.14001 104.157,7.38C 103.383,6.62 102.407,6.23999 101.233,6.23999C 100.012,6.23999 99.015,6.62872 98.24,7.40625C 97.465,8.18372 96.945,9.55499 96.68,11.52L 87.08,10.7325C 87.455,8.10248 88.145,6.04999 89.15,4.57495C 90.155,3.09998 91.5725,1.96875 93.4025,1.18121C 95.2325,0.393738 97.765,0 101,0C 104.375,0 107.001,0.382446 108.879,1.14746C 110.756,1.91248 112.233,3.08746 113.308,4.67249C 114.383,6.25745 114.92,8.03497 114.92,10.005C 114.92,12.1 114.309,14.1 113.086,16.005C 111.864,17.91 109.64,20.03 106.415,22.365C 104.5,23.725 103.219,24.6775 102.571,25.2225C 101.924,25.7675 101.165,26.48 100.295,27.36L 115.4,27.36L 115.4,35.04 Z " />
                </DrawingGroup.Children>
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>
    <DrawingBrush x:Key="Number3Brush"
                  Stretch="Uniform"
                  Viewbox="{StaticResource NumberViewbox}">
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <DrawingGroup.Children>
                    <GeometryDrawing Brush="#FFAC0200"
                                     Geometry="F1 M 118.16,100.56L 108.56,99.0375C 109.305,96.1225 110.736,93.8875 112.854,92.3325C 114.971,90.7775 117.967,90 121.842,90C 126.297,90 129.517,90.815 131.502,92.445C 133.487,94.075 134.48,96.1225 134.48,98.5875C 134.48,100.033 134.087,101.341 133.302,102.514C 132.517,103.686 131.332,104.715 129.747,105.6C 131.072,105.935 132.087,106.325 132.792,106.77C 133.932,107.49 134.819,108.435 135.451,109.605C 136.084,110.775 136.4,112.175 136.4,113.805C 136.4,115.845 135.877,117.801 134.832,119.674C 133.788,121.546 132.283,122.989 130.317,124.001C 128.353,125.014 125.772,125.52 122.577,125.52C 119.462,125.52 117.004,125.145 115.201,124.395C 113.399,123.645 111.917,122.55 110.757,121.11C 109.597,119.67 108.705,117.857 108.08,115.672L 117.68,114.48C 118.05,116.285 118.625,117.536 119.405,118.234C 120.185,118.931 121.177,119.28 122.382,119.28C 123.647,119.28 124.7,118.815 125.54,117.885C 126.38,116.955 126.8,115.717 126.8,114.172C 126.8,112.592 126.389,111.369 125.566,110.501C 124.744,109.634 123.627,109.2 122.217,109.2C 121.467,109.2 120.435,109.385 119.12,109.755L 119.615,102.855C 120.11,102.925 120.498,102.96 120.777,102.96C 121.947,102.96 122.924,102.602 123.706,101.887C 124.489,101.172 124.88,100.322 124.88,99.3375C 124.88,98.3975 124.606,97.6462 124.059,97.0837C 123.511,96.5212 122.76,96.24 121.805,96.24C 120.825,96.24 120.027,96.56 119.412,97.2C 118.797,97.84 118.38,98.96 118.16,100.56 Z " />
                </DrawingGroup.Children>
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>
    <DrawingBrush x:Key="Number4Brush"
                  Stretch="Uniform"
                  Viewbox="{StaticResource NumberViewbox}">
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <DrawingGroup.Children>
                    <GeometryDrawing Brush="#FF000379"
                                     Geometry="F1 M 262.4,107.8L 245.12,107.8L 245.12,99.8725L 262.4,79L 270.56,79L 270.56,100.12L 274.88,100.12L 274.88,107.8L 270.56,107.8L 270.56,114.04L 262.4,114.04L 262.4,107.8 Z M 262.4,100.12L 262.4,89.335L 253.422,100.12L 262.4,100.12 Z " />
                </DrawingGroup.Children>
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>
    <DrawingBrush x:Key="Number5Brush"
                  Stretch="Uniform"
                  Viewbox="{StaticResource NumberViewbox}">
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <DrawingGroup.Children>
                    <GeometryDrawing Brush="#FF7E0002"
                                     Geometry="F1 M 323.92,156.48L 346.96,156.48L 346.96,164.16L 331.233,164.16L 330.557,169.102C 331.623,168.572 332.675,168.176 333.715,167.914C 334.755,167.651 335.785,167.52 336.805,167.52C 340.245,167.52 343.038,168.574 345.182,170.681C 347.328,172.789 348.4,175.442 348.4,178.642C 348.4,180.892 347.845,183.055 346.735,185.13C 345.625,187.205 344.05,188.789 342.01,189.881C 339.97,190.974 337.36,191.52 334.18,191.52C 331.895,191.52 329.938,191.295 328.307,190.845C 326.677,190.395 325.291,189.722 324.149,188.827C 323.006,187.932 322.081,186.919 321.374,185.786C 320.666,184.654 320.075,183.242 319.6,181.552L 329.2,180.48C 329.44,182.05 330.004,183.242 330.891,184.057C 331.779,184.872 332.835,185.28 334.06,185.28C 335.43,185.28 336.563,184.794 337.458,183.821C 338.353,182.849 338.8,181.4 338.8,179.475C 338.8,177.5 338.36,176.054 337.48,175.136C 336.6,174.219 335.43,173.76 333.97,173.76C 333.045,173.76 332.153,173.977 331.292,174.413C 330.648,174.727 329.94,175.3 329.17,176.13L 321.04,175.005L 323.92,156.48 Z " />
                </DrawingGroup.Children>
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>
    <DrawingBrush x:Key="Number6Brush"
                  Stretch="Uniform"
                  Viewbox="{StaticResource NumberViewbox}">
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <DrawingGroup.Children>
                    <GeometryDrawing Brush="#FF007E79"
                                     Geometry="F1 M 493.44,177.512L 483.84,178.6C 483.6,177.37 483.195,176.502 482.625,175.997C 482.055,175.492 481.355,175.24 480.525,175.24C 479.02,175.24 477.853,176.005 477.022,177.535C 476.418,178.635 475.97,180.987 475.68,184.592C 476.825,183.372 478.002,182.469 479.212,181.881C 480.423,181.294 481.82,181 483.405,181C 486.48,181 489.081,182.094 491.209,184.281C 493.336,186.469 494.4,189.245 494.4,192.61C 494.4,194.875 493.865,196.945 492.795,198.82C 491.725,200.695 490.24,202.114 488.34,203.076C 486.44,204.039 484.06,204.52 481.2,204.52C 477.76,204.52 475.001,203.934 472.924,202.761C 470.846,201.589 469.186,199.719 467.944,197.151C 466.701,194.584 466.08,191.182 466.08,186.947C 466.08,180.747 467.374,176.206 469.961,173.324C 472.549,170.441 476.137,169 480.728,169C 483.438,169 485.579,169.324 487.151,169.971C 488.724,170.619 490.03,171.566 491.07,172.814C 492.11,174.061 492.9,175.627 493.44,177.512 Z M 475.995,192.64C 475.995,194.4 476.441,195.78 477.334,196.78C 478.226,197.78 479.318,198.28 480.608,198.28C 481.798,198.28 482.794,197.829 483.596,196.926C 484.399,196.024 484.8,194.675 484.8,192.88C 484.8,191.045 484.384,189.646 483.551,188.684C 482.719,187.721 481.685,187.24 480.45,187.24C 479.19,187.24 478.132,187.706 477.277,188.639C 476.423,189.571 475.995,190.905 475.995,192.64 Z " />
                </DrawingGroup.Children>
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>
    <DrawingBrush x:Key="Number7Brush"
                  Stretch="Uniform"
                  Viewbox="{StaticResource NumberViewbox}">
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <DrawingGroup.Children>
                    <GeometryDrawing Brush="#FFAA0408"
                                     Geometry="F1 M 381.08,261.48L 409.4,261.48L 409.4,267.622C 406.9,269.847 404.813,272.257 403.137,274.852C 401.108,278.002 399.502,281.51 398.323,285.375C 397.387,288.38 396.76,291.935 396.44,296.04L 386.84,296.04C 387.6,290.305 388.795,285.497 390.425,281.617C 392.055,277.737 394.633,273.585 398.158,269.16L 381.08,269.16L 381.08,261.48 Z " />
                </DrawingGroup.Children>
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>
    <DrawingBrush x:Key="Number8Brush"
                  Stretch="Uniform"
                  Viewbox="{StaticResource NumberViewbox}">
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <DrawingGroup.Children>
                    <GeometryDrawing Brush="#FFA5090D"
                                     Geometry="F1 M 620.87,333.057C 619.325,332.282 618.198,331.415 617.487,330.455C 616.522,329.145 616.04,327.637 616.04,325.932C 616.04,323.128 617.417,320.835 620.172,319.055C 622.323,317.685 625.165,317 628.7,317C 633.385,317 636.846,317.852 639.084,319.557C 641.321,321.262 642.44,323.41 642.44,326C 642.44,327.505 641.985,328.912 641.075,330.222C 640.395,331.197 639.323,332.142 637.857,333.057C 639.722,333.967 641.112,335.172 642.027,336.672C 642.942,338.172 643.4,339.832 643.4,341.652C 643.4,343.407 643.003,345.047 642.208,346.572C 641.412,348.097 640.435,349.275 639.275,350.105C 638.115,350.935 636.672,351.545 634.948,351.935C 633.222,352.325 631.382,352.52 629.427,352.52C 625.757,352.52 622.952,352.081 621.012,351.204C 619.073,350.326 617.599,349.034 616.591,347.326C 615.584,345.619 615.08,343.712 615.08,341.607C 615.08,339.547 615.552,337.802 616.497,336.372C 617.442,334.943 618.9,333.837 620.87,333.057 Z M 625.64,326.577C 625.64,327.592 625.981,328.41 626.664,329.03C 627.346,329.65 628.255,329.96 629.39,329.96C 630.395,329.96 631.221,329.654 631.869,329.041C 632.516,328.429 632.84,327.635 632.84,326.66C 632.84,325.645 632.503,324.821 631.827,324.189C 631.152,323.556 630.29,323.24 629.24,323.24C 628.175,323.24 627.309,323.55 626.641,324.17C 625.974,324.79 625.64,325.592 625.64,326.577 Z M 624.68,341.262C 624.68,342.737 625.149,343.943 626.086,344.878C 627.024,345.813 628.095,346.28 629.3,346.28C 630.46,346.28 631.5,345.805 632.42,344.855C 633.34,343.905 633.8,342.7 633.8,341.24C 633.8,339.765 633.336,338.556 632.409,337.614C 631.481,336.671 630.405,336.2 629.18,336.2C 627.975,336.2 626.924,336.656 626.026,337.569C 625.129,338.481 624.68,339.712 624.68,341.262 Z " />
                </DrawingGroup.Children>
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>

    <Style TargetType="{x:Type c:MineCellControl}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding IsPressed}"
                     Value="True">
                <Setter Property="Background"
                        Value="{DynamicResource PressedCellBackground}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding MinesNearby}"
                         Value="1">
                <Setter Property="Foreground"
                        Value="{DynamicResource Number1Brush}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding MinesNearby}"
                         Value="2">
                <Setter Property="Foreground"
                        Value="{DynamicResource Number2Brush}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding MinesNearby}"
                         Value="3">
                <Setter Property="Foreground"
                        Value="{DynamicResource Number3Brush}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding MinesNearby}"
                         Value="4">
                <Setter Property="Foreground"
                        Value="{DynamicResource Number4Brush}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding MinesNearby}"
                         Value="5">
                <Setter Property="Foreground"
                        Value="{DynamicResource Number5Brush}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding MinesNearby}"
                         Value="6">
                <Setter Property="Foreground"
                        Value="{DynamicResource Number6Brush}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding MinesNearby}"
                         Value="7">
                <Setter Property="Foreground"
                        Value="{DynamicResource Number7Brush}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding MinesNearby}"
                         Value="8">
                <Setter Property="Foreground"
                        Value="{DynamicResource Number8Brush}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding State}"
                         Value="{x:Static logic:CellState.Normal}">
                <Setter Property="Foreground"
                        Value="Transparent" />
            </DataTrigger>
            <DataTrigger Binding="{Binding State}"
                         Value="{x:Static logic:CellState.Shown}">
                <Setter Property="Background"
                        Value="{DynamicResource ShownCellBackground}" />
            </DataTrigger>
            <DataTrigger Binding="{Binding State}"
                         Value="{x:Static logic:CellState.MarkAsMine}">
                <Setter Property="Mark"
                        Value="{DynamicResource FlagBrush}" />
                <Setter Property="Foreground"
                        Value="Transparent" />
            </DataTrigger>
            <DataTrigger Binding="{Binding State}"
                         Value="{x:Static logic:CellState.Question}">
                <Setter Property="Mark"
                        Value="{DynamicResource QuestionBrush}" />
                <Setter Property="Foreground"
                        Value="Transparent" />
            </DataTrigger>
            <DataTrigger Binding="{Binding TooManyFlagsAround}"
                         Value="True">
                <Setter Property="Background" Value="{DynamicResource TooManyFlagsBrush}" />
            </DataTrigger>
            <!-- Shows a un-marked mine. -->
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding ShowResult}"
                               Value="True" />
                    <Condition Binding="{Binding HasMine}"
                               Value="True" />
                    <Condition Binding="{Binding State}"
                               Value="{x:Static logic:CellState.Normal}" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Foreground"
                        Value="{DynamicResource MineBrush}" />
                <!--This setter should only work for XP style.-->
                <Setter Property="Mark"
                        Value="Transparent" />
            </MultiDataTrigger>
            <!-- Shows a wrong marked mine. -->
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding ShowResult}"
                               Value="True" />
                    <Condition Binding="{Binding State}"
                               Value="{x:Static logic:CellState.MarkAsMine}" />
                    <Condition Binding="{Binding HasMine}"
                               Value="False" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Foreground"
                        Value="{DynamicResource FlagBrush}" />
                <Setter Property="Mark"
                        Value="{DynamicResource WrongMineMark}" />
            </MultiDataTrigger>
            <DataTrigger Binding="{Binding IsTerminator}"
                         Value="True">
                <Setter Property="Foreground"
                        Value="{DynamicResource BomMineBrush}"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <SolidColorBrush x:Key="WindowBackgroundBrush" Color="#FFF2F1F0" />

    <Style x:Key="MainWindowStyle"
           TargetType="{x:Type Window}" BasedOn="{StaticResource {x:Type Window}}">
        <Style.Resources>
            <Style x:Key="WindowButtonStyle" TargetType="{x:Type Button}">
                <Setter Property="BorderThickness" Value="1" />
                <Setter Property="BorderBrush" Value="#FF383734"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Button}">
                            <Grid>
                                <Ellipse Width="17" Height="17"
                                         Fill="{TemplateBinding Background}"
                                         Stroke="{TemplateBinding BorderBrush}"
                                         StrokeThickness="{TemplateBinding BorderThickness}" />
                                <Path Stroke="{TemplateBinding Foreground}"
                                      Stretch="None" StrokeThickness="1"
                                      Data="{TemplateBinding DataContext}"
                                      VerticalAlignment="Center" HorizontalAlignment="Center" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Path=IsActive, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" Value="False">
                        <DataTrigger.Setters>
                            <Setter Property="Background" Value="#FF5C5B55" />
                        </DataTrigger.Setters>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            <Style x:Key="SizeButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource WindowButtonStyle}">
                <Setter Property="Foreground" Value="#FF3A3935" />
                <Setter Property="Background">
                    <Setter.Value>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="#FF8C8B85" Offset="0" />
                            <GradientStop Color="#FF5A5A55" Offset="1" />
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Trigger.Setters>
                            <Setter Property="Background">
                                <Setter.Value>
                                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                        <GradientStop Color="#FFCCCCCC" Offset="0" />
                                        <GradientStop Color="#FF959595" Offset="1" />
                                    </LinearGradientBrush>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Foreground" Value="#FF62625F" />
                        </Trigger.Setters>
                    </Trigger>
                    <Trigger Property="IsPressed" Value="True">
                        <Trigger.Setters>
                            <Setter Property="Background" Value="#FF75746D" />
                            <Setter Property="Foreground" Value="#FF3A3935"/>
                        </Trigger.Setters>
                    </Trigger>
                </Style.Triggers>
            </Style>
            <Style x:Key="MinButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource SizeButtonStyle}">
                <Setter Property="DataContext">
                    <Setter.Value>
                        <StreamGeometry>M0,0.5 L7,0.5</StreamGeometry>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="RestoreButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource SizeButtonStyle}">
                <Setter Property="DataContext">
                    <Setter.Value>
                        <StreamGeometry>M0.5,0.5 L0.5,6.5 L6.5,6.5 L6.5,0.5 Z</StreamGeometry>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="CloseButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource WindowButtonStyle}">
                <Setter Property="Foreground" Value="#FF402013" />
                <Setter Property="DataContext">
                    <Setter.Value>
                        <StreamGeometry>M0,0 L5,5 M0,5 L5,0</StreamGeometry>
                    </Setter.Value>
                </Setter>
                <Setter Property="Background">
                    <Setter.Value>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="#FFF79674" Offset="0" />
                            <GradientStop Color="#FFDF5106" Offset="1" />
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Trigger.Setters>
                            <Setter Property="Background">
                                <Setter.Value>
                                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                        <GradientStop Color="#FFFEAF95" Offset="0" />
                                        <GradientStop Color="#FFE45306" Offset="1" />
                                    </LinearGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Trigger.Setters>
                    </Trigger>
                    <Trigger Property="IsPressed" Value="True">
                        <Trigger.Setters>
                            <Setter Property="Background" Value="#FFEE703B" />
                        </Trigger.Setters>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </Style.Resources>
        <Setter Property="WindowStyle" Value="None"/>
        <Setter Property="ResizeMode" Value="NoResize"/>
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Background" Value="{DynamicResource WindowBackgroundBrush}"/>
        <Setter Property="BorderBrush">
            <Setter.Value>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Color="#FF3C3B37" Offset="0" />
                    <GradientStop Color="#FF3C3B37" Offset="0.2" />
                    <GradientStop Color="#FFADA9A5" Offset="0.3" />
                    <GradientStop Color="#FFADA9A5" Offset="1" />
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Window}">
                    <ContentControl Style="{StaticResource ResizableWindowBorderStyle}">
                        <Border Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="5,5,0,0">
                            <DockPanel>
                                <Border BorderThickness="0,1,0,0" CornerRadius="3,3,0,0"
                                        BorderBrush="#FF626059" Height="28" DockPanel.Dock="Top">
                                    <Border.Background>
                                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                            <GradientStop Color="#FF474642" Offset="0" />
                                            <GradientStop Color="#FF474642" Offset="0.33" />
                                            <GradientStop Color="#FF3C3B37" Offset="0.5" />
                                            <GradientStop Color="#FF3C3B37" Offset="1" />
                                        </LinearGradientBrush>
                                    </Border.Background>
                                    <Interaction.Behaviors>
                                        <BehaviorCollection>
                                            <DragMoveBehavior />
                                        </BehaviorCollection>
                                    </Interaction.Behaviors>
                                    <DockPanel>
                                        <Border Height="19"
                                                Margin="10,0,0,0"
                                                BorderThickness="1"
                                                BorderBrush="#FF3A3935"
                                                Background="#FF3C3B37"
                                                CornerRadius="9">
                                            <DockPanel>
                                                <Button Style="{StaticResource CloseButtonStyle}" Command="Close" />
                                                <Button Name="minButton" Style="{StaticResource MinButtonStyle}" Command="{x:Static d:UICommands.Minimize}" />
                                                <Button Name="maxButton" Style="{StaticResource RestoreButtonStyle}" Command="{x:Static d:UICommands.Maximize}" />
                                            </DockPanel>
                                        </Border>
                                        <Label Content="{TemplateBinding Title}"
                                               Margin="7,0,0,0" VerticalAlignment="Center"
                                               FontWeight="Bold" Name="title"
                                               Foreground="#FFDFDBD2" HorizontalAlignment="Left" />
                                    </DockPanel>
                                </Border>
                                <AdornerDecorator>
                                    <ContentPresenter/>
                                </AdornerDecorator>
                            </DockPanel>
                        </Border>
                    </ContentControl>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsActive" Value="False">
                            <Setter TargetName="title" Property="Foreground" Value="#FF807D78"/>
                        </Trigger>
                        <Trigger Property="c:WindowExt.ResizeMode" Value="NoResize">
                            <Setter TargetName="minButton" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="maxButton" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="WindowStyle" Value="ToolWindow">
                            <Setter TargetName="minButton" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="maxButton" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <DataTemplate x:Key="{x:Type vm:ClearMineViewModel}" DataType="{x:Type vm:ClearMineViewModel}">
        <Grid x:Name="root" c:CommandsHelper.LoadBindingsFromVM="True"
              Background="{DynamicResource WindowBackgroundBrush}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="5" />
                <RowDefinition Height="Auto"
                               MinHeight="36" />
                <RowDefinition Height="5" />
                <RowDefinition Height="7*" />
                <RowDefinition Height="5" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="10" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="5" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="5" />
            </Grid.ColumnDefinitions>
            <Menu Grid.ColumnSpan="3"
                  ItemContainerStyle="{DynamicResource GeneratedMenuStyle}"
                  ItemsSource="{Binding Source={x:Static u:Infrastructure.MenuDefinition}}" />
            <Button Command="New"
                    Margin="18,0,18,4"
                    Grid.Row="2"
                    Grid.ColumnSpan="3"
                    HorizontalAlignment="Center"
                    UseLayoutRounding="True"
                    Style="{DynamicResource NewGameButtonStyle}">
                <Border x:Name="newGameIcon" Width="32" Height="32" Margin="4"
                        Background="{DynamicResource NormalFaceBrush}" />
            </Button>
            <Separator HorizontalAlignment="Stretch"
                       Height="1"
                       Grid.Row="3"
                       VerticalAlignment="Center"
                       Grid.ColumnSpan="3"
                       Background="#FFD3D0CD">
                <Separator.Effect>
                    <!--I set the color exactly like ubuntu, but it is not as obvious as ubuntu's. Why?-->
                    <DropShadowEffect Color="#FFFAF9F9" Direction="270" BlurRadius="0" ShadowDepth="1" />
                </Separator.Effect>
            </Separator>
            <Decorator x:Name="playground"
                       Grid.Row="4"
                       Grid.Column="1">
                <Border BorderBrush="{DynamicResource PlaygroundBorderBrush}"
                        VerticalAlignment="Center"
                        HorizontalAlignment="Center">
                    <ItemsControl x:Name="cellsPanel"
                                  IsTabStop="False"
                                  ItemsSource="{Binding Cells}">
                        <Interaction.Behaviors>
                            <BehaviorCollection>
                                <MainInteractionBehavior />
                            </BehaviorCollection>
                        </Interaction.Behaviors>
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <MinesPanel Rows="{Binding Rows}"
                                            Columns="{Binding Columns}"
                                            ItemSize="{Binding ItemSize, Mode=OneWayToSource}"
                                            GridLineBrush="Gray"
                                            GridLineThickness="2" />
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                    </ItemsControl>
                </Border>
            </Decorator>
            <Separator HorizontalAlignment="Stretch"
                       Height="1"
                       Grid.Row="5"
                       VerticalAlignment="Center"
                       Grid.ColumnSpan="3"
                       Background="#FFD3D0CD" >
                <Separator.Effect>
                    <DropShadowEffect Color="#FFFAF9F9" Direction="270" BlurRadius="0" ShadowDepth="1" />
                </Separator.Effect>
            </Separator>
            <DockPanel LastChildFill="False"
                       Grid.Row="6"
                       Grid.Column="1"
                       Margin="0,5,0,0"
                       Width="{Binding ActualWidth, ElementName=cellsPanel}"
                       HorizontalAlignment="Center"
                       UseLayoutRounding="True">
                <Label Content="{DynamicResource FlagsLabel}"
                       Margin="25,0,5,0" Foreground="#FF4C4C4C" />
                <TextBlock Foreground="#FF4C4C4C">
                    <TextBlock.Text>
                        <MultiBinding StringFormat="{}{0}/{1}">
                            <Binding Path="Flags"/>
                            <Binding Path="TotalMines"/>
                        </MultiBinding>
                    </TextBlock.Text>
                </TextBlock>
                <TextBlock Text="{Binding DigitalTime, StringFormat=hh\\:mm\\:ss}"
                           Margin="5,0,25,0" Foreground="#FF4C4C4C"
                           DockPanel.Dock="Right" />
                <Label Content="{DynamicResource TimesLabel}"
                       DockPanel.Dock="Right" Foreground="#FF4C4C4C" />
            </DockPanel>
        </Grid>
        <DataTemplate.Resources>
            <!--While, this animation is slow on my machine.-->
            <Storyboard x:Key="BlurPlayground" Duration="00:00:01">
                <DoubleAnimation From="0" To="40" AutoReverse="True" FillBehavior="HoldEnd"
                                 Storyboard.TargetName="playground"
                                 Storyboard.TargetProperty="(UIElement.Effect).(BlurEffect.Radius)"/>
            </Storyboard>
        </DataTemplate.Resources>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsPaused}" Value="True">
                <Setter Property="Effect"
                        TargetName="cellsPanel">
                    <Setter.Value>
                        <MonoEffect />
                    </Setter.Value>
                </Setter>
                <Setter Property="Effect"
                        TargetName="playground">
                    <Setter.Value>
                        <BlurEffect Radius="0" />
                    </Setter.Value>
                </Setter>
                <DataTrigger.EnterActions>
                    <BeginStoryboard x:Name="blurStoryboard" Storyboard="{StaticResource BlurPlayground}" />
                </DataTrigger.EnterActions>
                <DataTrigger.ExitActions>
                    <StopStoryboard BeginStoryboardName="blurStoryboard" />
                </DataTrigger.ExitActions>
            </DataTrigger>
            <DataTrigger Binding="{Binding State}" Value="{x:Static logic:GameState.Success}">
                <Setter Property="Background"
                        TargetName="newGameIcon"
                        Value="{DynamicResource WinFaceBrush}">
                </Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding State}" Value="{x:Static logic:GameState.Failed}">
                <Setter Property="Background"
                        TargetName="newGameIcon"
                        Value="{DynamicResource LosingFaceBrush}">
                </Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding IsMousePressed}" Value="True">
                <Setter Property="Background"
                        TargetName="newGameIcon"
                        Value="{DynamicResource TryFaceBrush}">
                </Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding State}" Value="{x:Static logic:GameState.Initialized}">
                <Setter Property="Background"
                        TargetName="newGameIcon"
                        Value="{DynamicResource PreparedFaceBrush}">
                </Setter>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
</ResourceDictionary>